package com.project.entity.sys;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name="S_MENU")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DynamicInsert
@DynamicUpdate
public class SysMenu extends BaseEntity  {

	private static final long serialVersionUID = 1L;

	@Column(name = "name",length = 100)
	private String name;//菜单名称
	
	@Column(name = "parent_id")
	private Long parentId;//父id
	
	@Column(name = "sort")
	private Integer sort;//排序 倒序
	
	@Column(name = "permissions_id")
	private Long permissionsId;//权限主键
	
	@Column(name = "url", length = 100)
	private String url;//菜单url
	
	@Column(name = "icon", length = 100)
	private String icon;//菜单图标
	
	@OneToMany(fetch=FetchType.EAGER)
	@JoinColumns(value={@JoinColumn(name="parent_id",referencedColumnName="id",updatable=false,insertable=false)})
	@OrderBy("sort")
	private List<SysMenu> menus;
	
	@OneToOne
	@JoinColumn(name="permissions_id",referencedColumnName="id",insertable=false,updatable=false)
	private Permissions permissions;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getParentId() {
		return parentId;
	}

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public List<SysMenu> getMenus() {
		return menus;
	}

	public void setMenus(List<SysMenu> menus) {
		this.menus = menus;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public Long getPermissionsId() {
		return permissionsId;
	}

	public void setPermissionsId(Long permissionsId) {
		this.permissionsId = permissionsId;
	}

	public Permissions getPermissions() {
		return permissions;
	}

	public void setPermissions(Permissions permissions) {
		this.permissions = permissions;
	}
}
